<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div id="test">hello world</div>
    <script>
        /* 
        this指向当前正在执行的属性
        解决了函数内部this关键字的指向问题 
        当函数直接调用时，this指向window

        */  
        var test=document.getElementById("test")  ;
        test.onclick=function(){
            setTimeout(()=>{ 
                console.log(this)    //div
            },300)     
        }  
       /*  test.onclick=function(){
           console.log(this)   //div
            go()
         }
        function go(){
            console.log(this)    //window
        }  */
       // test.onclick=go;
    </script>
</body>
</html>